window.onload = function () {
    axios.post("http://localhost:8081/admin/remember").then(res => {
        if(res.data.state){
            var username = document.getElementById("username");
            var password = document.getElementById("password");
            username.value = res.data.username;
            password.value = res.data.password;
        }else{
            username.value = "";
            password.value = "";
        }
    })
}

var remember = true;
function setRememberMe(){
    remember = !remember;
    console.log(remember);
}
function toLogin(){
    var username = document.getElementById("username");
    var password = document.getElementById("password");

    if(username.value === ""){
        alert("请输入用户名！");
    }else if(password.value === ""){
        alert("请输入密码！");
    }else{
        axios.post("http://localhost:8081/admin/login",{"username":username.value,
            "password":password.value,"rememberMe":remember}).then(res => {
            if (res.data.state) {
                location.href = "MembershipManagement.html";
            } else {
                alert(res.data.msg)
            }
        })
    }
}